<?php
/**
 *
 *
 * @author Zeon <scplay@gmail.com>
 * @date 2019/5/28 14:36
 * @copyright PanxSoft Inc.
 */

namespace App\Http\Controllers\App\V1;


use App\Http\Controllers\ApiController;
use App\Models\DevicePreset;
use Illuminate\Http\Request;

class DevicePresetController extends ApiController
{
    const ROUTES = [
        'index'   => 'app.v1.UserDevicePreset.index',
    ];

    /**
     * 设备预设列表
     *
     * @param Request $request
     *
     * @return array|\Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $device_presets = (new DevicePreset)
            ->filterWhen('device_id', $request->get('device_id'))
            ->oldest('sort_order')
            ->latest('created_at')
            ->with('localeDescription')
            ->where('is_show', DevicePreset::IS_SHOW)
            ->get();

        return $this->response(compact('device_presets'));
    }
}